//
//  SSUserOrderCell.swift
//  拾舍清洁
//
//  Created by sky.wei on 2023/3/1.
//

import UIKit

class SSUserOrderCell: UITableViewCell {
    @IBOutlet weak var imageV: UIImageView!
    
    @IBOutlet weak var priceLab: UILabel!
    @IBOutlet weak var specLab: UILabel!
    @IBOutlet weak var titleLab: UILabel!
    override func awakeFromNib() {
        super.awakeFromNib()
        imageV.layer.masksToBounds = true
        imageV.layer.cornerRadius = 10
        selectionStyle = .none
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }
    
    func setData(model:ListCombo) {
        let optionalString: String = model.fee
        var itemFee:Float = Float(optionalString) ?? 0
        var specNames:String = ""
        for (i, spec) in model.specs.enumerated() {
            if i == 0 {
                specNames = "规格：\(specNames)\(spec.name)"
            }else{
                specNames = "\(specNames)，\(spec.name)"
            }
            let optionalString: String = spec.fee
            let specFee:Float = Float(optionalString) ?? 0
            itemFee = itemFee + specFee
        }
        titleLab.text = model.name
        imageV.setImage(with: model.imgUrl, placeholderImage: UIImage(named: "place_holder_icon"))
        specLab.text = specNames
        priceLab.text = "$\(itemFee)"
    }
    
}
